package com.giscloud.commons.model;

import java.io.Serializable;

/**
 * @Author:giscloud
 * @Description:
 * @Date: 9:11 2019/9/12
 * @Modified By:
 */
public class BaseDTO implements Serializable {

    private static final long serialVersionUID = -1932987797833906727L;

    public final static String DIRECTION_DESC = "DESC";

    public final static String DIRECTION_ASC = "ASC";

    private int start;

    private int end;

    /**
     * 页码
     */
    private int page = 1;

    /**
     * 显示条数
     */
    private int rows = 10;

    // 数据库字段名
    private String sort;

    // 方向
    private String dir;

    //旧值
    private Object oldValue;

    private boolean needPagination;

    //操作人ID
    private Long userId;

    public int getStart() {
        start = (this.getPage() - 1) * this.getRows();
        return start;
    }

    public int getEnd() {
        end = this.getPage() * this.getRows();
        return end;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getDir() {
        return dir;
    }

    public void setDir(String dir) {
        this.dir = dir;
    }

    public boolean isNeedPagination() {
        return needPagination;
    }

    public void setNeedPagination(boolean needPagination) {
        this.needPagination = needPagination;
    }

    public int getPage() {
        if (page < 1) {
            page = 1;
        }
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        if (rows < 0) {
            rows = 10;
        }
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Object getOldValue() {
        return oldValue;
    }

    public void setOldValue(Object oldValue) {
        this.oldValue = oldValue;
    }
}
